package com.zood.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zood.dao.ShowDao;
import com.zood.dao.StoneDao;
import com.zood.domain.show;
import com.zood.domain.stone;
import com.zood.service.showService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class showServiceImpl extends ServiceImpl<ShowDao, show> implements showService {
    @Autowired
    private ShowDao show;

    @Autowired
    private StoneDao stone;

    //得到活动的总数
    public int getCount(){
        int users =  show.getCount();
        return users;
    }

    //通过模板id得到数据
    public List<show> getALLbyID(int id){
        List<com.zood.domain.show> users = show.getAllById(id);
        return users;
    }

    //通过mid和tid得到数据
//    public List<show> getALLbyID1(int mid,int tid){
//        List<com.zood.domain.show> users = show.getAllById1(mid,tid);
//        return users;
//    }

   public List<show> getALLbyID1(int mid,int tid){
        List<com.zood.domain.show> users = show.getAllById1(mid,tid);
        List<com.zood.domain.stone> stones= stone.getAll1();
        List<show> users1 = new ArrayList<>();


        for(int i=0;i<stones.size();i++){
            show myshow=new show();
            String stoneName2=stones.get(i).getSname();
            myshow.setSname(stoneName2);
            myshow.setSid(stones.get(i).getId());
            users1.add(myshow);
            for (int j=0;j<users.size();j++){
                if(users.get(j).getSname().equals(stones.get(i).getSname())){
                    show myshow1=new show();
                    myshow1.setAchievement(users.get(j).getAchievement());
                    myshow1.setAname(users.get(j).getAname());
                    myshow1.setBonus(users.get(j).getBonus());
                    myshow1.setFront(users.get(j).getBonus());
                    myshow1.setIscrop(users.get(j).isIscrop());
                    myshow1.setQuota(users.get(j).getQuota());
                    myshow1.setProcess(users.get(j).getProcess());
                    myshow1.setType(users.get(j).getType());

                    myshow1.setAid(users.get(j).getAid());
                    myshow1.setMid(users.get(j).getMid());
                    myshow1.setSid(users.get(j).getSid());
                    myshow1.setTid(users.get(j).getTid());
                    myshow1.setSmid(users.get(j).getSmid());
                    myshow1.setMtid(users.get(j).getMtid());
                    myshow1.setAsid(users.get(j).getAsid());

                    users1.add(myshow1);
                }
            }
        }

        return users1;
    }



}
